package net.diaowen.dwsurvey.entity;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.Entity;
import javax.persistence.Table;
import javax.persistence.Transient;

import lombok.Data;
import net.diaowen.common.base.entity.IdEntity;
import net.diaowen.common.YesnoOption;
import net.diaowen.common.CheckType;
import net.diaowen.common.QuType;

/**
 * @author keyuan
 * <p>
 * https://github.com/wkeyuan/DWSurvey
 * http://dwsurvey.net
 */
@Entity
@Table(name = "t_question")
@Data
public class Question extends IdEntity {

    //所属问卷或题库
    private String belongId;
    //题目名称
    private String quName;
    // 题干
    private String quTitle;
    // 题目说明
    private String quNote;
    // 关键字
    private String keywords;
    // 题目类型
    private QuType quType;
    // 标记     1题库中的题   2问卷中的题
    private Integer tag;
    // 排序ID
    private Integer orderById;
    // 创建时间
    private Date createDate = new Date();
    // 是否是大小题    1默认题  2大题  3大题下面的小题
    private Integer quTag = 1;
    // 所属大题  只有小题才有此属性 即quTag=3的题
    private String parentQuId;
    // 是非题的选项
    private YesnoOption yesnoOption;
    // 是否必答 0非必答 1必答
    private Integer isRequired = 0;
    //说明的验证方式
    private CheckType checkType;
    // 枚举题 枚举项数目 ,评分题起始分值
    private Integer paramInt01 = 0;
    //评分题，最大分值
    private Integer paramInt02 = 0;
    //上传excel题，是否格式化存储：1-不格式化 2-格式化存储
    private Integer paramInt03 = 0;
    //是否显示 0不显示   1显示
    private Integer visibility = 1;
    //如果是复制的题，则有复制于那一题
    public String copyFromId;

    //控制性属性
    //1水平显示 2垂直显示
    private Integer hv = 2;
    //选项随机排列  1随机排列 0不随机排列
    private Integer randOrder = 0;
    //按列显示时，列数
    private Integer cellCount = 0;

    //联系人属性
    //1关联到联系人属性  0不关联到联系人属性
    private Integer contactsAttr = 0;
    //关联的联系人字段
    private String contactsField;

    //填空的input
    private Integer answerInputWidth;
    private Integer answerInputRow;


    /**
     * 附加属性，不作映射
     */
    private List<Question> questions = new ArrayList<Question>();
    //题选项
    private List<QuRadio> quRadios = new ArrayList<QuRadio>();
    private List<QuCheckbox> quCheckboxs = new ArrayList<QuCheckbox>();
    private List<QuMultiFillblank> quMultiFillblanks = new ArrayList<QuMultiFillblank>();
    private List<QuScore> quScores = new ArrayList<QuScore>();
    private List<QuOrderby> quOrderbys = new ArrayList<QuOrderby>();
    private String rowContent = "";
    private String colContent = "";
    private String optionContent = "";
    //删除的ID
    private String[] removeOptionUuIds = null;
    //题答卷
    private AnAnswer anAnswer = new AnAnswer();
    private List<AnCheckbox> anCheckboxs = new ArrayList<AnCheckbox>();
    private List<AnDFillblank> anDFillblanks = new ArrayList<AnDFillblank>();
    private List<AnEnumqu> anEnumqus = new ArrayList<AnEnumqu>();
    private AnFillblank anFillblank = new AnFillblank();
    private AnRadio anRadio = new AnRadio();
    private AnYesno anYesno = new AnYesno();
    private List<AnScore> anScores = new ArrayList<AnScore>();
    private Integer anCount = 0;
    private List<AnOrder> anOrders = new ArrayList<AnOrder>();
    private List<AnUplodFile> anUplodFiles = new ArrayList<AnUplodFile>();
    //逻辑设置
    private List<QuestionLogic> questionLogics;
    //统计json
    public String statJson = "";
    //excel模板(filePath___fileName),例如：\image\0e9lks6oi.jpg___user.jpg
    private QuExcelTemplate quExcelTemplate;

    @Transient
    public List<QuRadio> getQuRadios() {
        return quRadios;
    }

    @Transient
    public List<QuCheckbox> getQuCheckboxs() {
        return quCheckboxs;
    }

    @Transient
    public List<QuMultiFillblank> getQuMultiFillblanks() {
        return quMultiFillblanks;
    }

    @Transient
    public List<QuScore> getQuScores() {
        return quScores;
    }

    @Transient
    public List<QuOrderby> getQuOrderbys() {
        return quOrderbys;
    }

    @Transient
    public String getRowContent() {
        return rowContent;
    }

    @Transient
    public String getColContent() {
        return colContent;
    }

    @Transient
    public String getOptionContent() {
        return optionContent;
    }

    @Transient
    public String[] getRemoveOptionUuIds() {
        return removeOptionUuIds;
    }

    @Transient
    public List<Question> getQuestions() {
        return questions;
    }

    @Transient
    public AnAnswer getAnAnswer() {
        return anAnswer;
    }

    @Transient
    public List<AnCheckbox> getAnCheckboxs() {
        return anCheckboxs;
    }

    @Transient
    public List<AnDFillblank> getAnDFillblanks() {
        return anDFillblanks;
    }

    @Transient
    public List<AnEnumqu> getAnEnumqus() {
        return anEnumqus;
    }

    @Transient
    public AnFillblank getAnFillblank() {
        return anFillblank;
    }

    @Transient
    public AnRadio getAnRadio() {
        return anRadio;
    }

    @Transient
    public AnYesno getAnYesno() {
        return anYesno;
    }

    @Transient
    public List<AnScore> getAnScores() {
        return anScores;
    }

    @Transient
    public Integer getAnCount() {
        return anCount;
    }

    @Transient
    public List<QuestionLogic> getQuestionLogics() {
        return questionLogics;
    }

    @Transient
    public List<AnOrder> getAnOrders() {
        return anOrders;
    }

    @Transient
    public List<AnUplodFile> getAnUplodFiles() {
        return anUplodFiles;
    }

    @Transient
    public String getStatJson() {
        return statJson;
    }

    @Transient
    public QuExcelTemplate getQuExcelTemplate() {
        return quExcelTemplate;
    }
}
